Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
Search form input - Search "as you type" with HTML/Javascript

I have following search form in an HTML page on website built with Django:

<form method="get">
<input class="form-control" type="text" name="q" id="id_q" placeholder="Search...">
</form>

I would like it to perform a search while typing (not having to press enter). I know we could use onchange or onkeyup, but I don't seem to be able to make it work.

The javascript at the bottom of the page is as follows:

<script type="text/javascript">
document.getElementById("id_q").value = "{{query}}"
</script>

Edit: I saw that my search works without the Javascript part above, but I still need to press on Enter. What would be a simple script to launch the search "as you type" without pressing Enter?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

once you onchange you can get your current values and send a API request or anything you want to do something like below-

window.addEventListener('load', () => {
  const input = document.getElementById("id_q");
  input.addEventListener('change', (e) => {
    let currentVal=e.target.value;
    // do anything with this value
  })
})

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda